using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;

namespace shfa.snomtastic.data
{
    public partial class SqlDataProvider
    {

        public Guid InsertAppConfig(string name, string value)
		{
            return new Guid(Convert.ToString(SqlHelper.ExecuteScalar(ConnectionString, "sp_AppConfigInsert", name, value)));
		}

        public int UpdateAppConfig(Guid id, string name, string value)
		{
            return Convert.ToInt32(SqlHelper.ExecuteScalar(ConnectionString, "sp_AppConfigUpdate", GetNull(id), name, value));
		}

        public int DeleteAppConfig(Guid id) 
		{
            return Convert.ToInt32(SqlHelper.ExecuteScalar(ConnectionString, "sp_AppConfigDelete", id));
		}

        public DataRow SelectAppConfig(Guid id) 
        {    
			DataSet ds = SqlHelper.ExecuteDataset(ConnectionString, "sp_AppConfigSelect", id);
            if (ds.Tables.Count > 0)
                if (ds.Tables[0].Rows.Count > 0)
                    return ds.Tables[0].Rows[0];

            return null;
		}

		public DataTable SelectAppConfigs() 
		{
            return SqlHelper.ExecuteDataset(ConnectionString, "sp_AppConfigSelectAll").Tables[0];
        }

    }

}
